package swingxrcp.framework.server.action;

import java.io.Serializable;

import swingxrcp.framework.model.Action;
import swingxrcp.framework.model.environment.MessageSource;
import swingxrcp.framework.util.log.Logger;
import swingxrcp.framework.util.log.LoggerFactory;

/**
 * 抽象Action基类 (支持泛型处理)
 *
 * @author liangfei
 * @since 2008-10-25
 */
public abstract class AbstractAction<T extends Serializable> implements Action {

	/**
	 * 日志输出接口
	 */
	protected final Logger logger = LoggerFactory.getLogger(getClass());

	/**
	 * 国际化信息源
	 */
	protected MessageSource messageSource;

	public void setMessageSource(MessageSource messageSource) {
		this.messageSource = messageSource;
	}

	// 接口适配
	@SuppressWarnings("unchecked")
	public final Serializable execute(Serializable object) {
		return doExecute((T)object);
	}

	/**
	 * 执行Action
	 *
	 * @param object 传入对象
	 * @return 传回对象
	 */
	public abstract Serializable doExecute(T object);

}
